<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>商品添加</title>
    <link rel="stylesheet" type="text/css" th:href="@{/css/admin_index.css}">
</head>
<body>

    <div class="frm">
        <div class="title">图书信息添加:</div>
        <form th:action="@{/admin/goods/add}" method="post" enctype="multipart/form-data">
            <table>
                <tr>
                    <td>ISBN编号:</td>
                    <td>
                        <input type="text" name="isbn" required="required"/>
                    </td>
                </tr>

                <tr>
                    <td>图书名称:</td>
                    <td>
                        <input type="text" name="name" required="required"/>
                    </td>
                </tr>

                <tr>
                    <td>作者:</td>
                    <td>
                        <input type="text" name="author" required="required"/>
                    </td>
                </tr>

                <tr>
                    <td>出版社:</td>
                    <td>
                        <input type="text" name="publisher" required="required"/>
                    </td>
                </tr>

                <tr>
                    <td>出版时间:</td>
                    <td>
                        <input type="text" name="publishDate" placeholder="2021-4-1" required="required"/>
                    </td>
                </tr>

                <tr>
                    <td>原价:</td>
                    <td>
                        <input type="text" name="oldPrice" required="required"/>
                    </td>
                </tr>

                <tr>
                    <td>现价:</td>
                    <td>
                        <input type="text" name="newPrice" required="required"/>
                    </td>
                </tr>

                <tr>
                    <td>作者地区:</td>
                    <td>
                        <input type="text" name="authorLoc" required="required"/>
                    </td>
                </tr>

                <tr>
                    <td>描述:</td>
                    <td>
                        <br/>
                        <textarea name="info"></textarea>
                    </td>
                </tr>

                <tr>
                    <td>是否套装:</td>
                    <td>
                        <div>
                            <input type="radio" name="suit"  value="YES">
                            <label>是</label>
                        </div>
                        <div>
                            <input type="radio" name="suit"  value="NO">
                            <label>否</label>
                        </div>
                    </td>
                </tr>

                <tr>
                    <td>图书分类</td>
                    <td>
                        <select name="category">
                            <option value="SELECTED" >精选图书</option>
                            <option value="RECOMMEND" >推荐图书</option>
                            <option value="BARGAIN" >特价图书</option>
                        </select>
                    </td>
                </tr>

                <tr>
                    <td>图片</td>
                    <td>
                        <img th:src="@{/img/mr.jpg}" width="80" height="100" id="img"/>
                        <br/>
                        <input type="file" name="file" id="file" onchange="showImg()"/>
                    </td>
                </tr>

                <tr>
                    <td>
                        <input type="submit" value="提交"/>
                    </td>
                </tr>
            </table>
        </form>
    </div>


<script type="text/javascript">
    function showImg() {
        //文件框选择图片时 图片框自动切换
        var f = new FileReader();
        f.onload = function (ev) {
            img.src = ev.target.result;
        };

        f.readAsDataURL(file.files[0]);
    }
</script>
</body>
</html>